home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TOptSolution.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  5.8 KB  |  147 lines  |  [TEXT/MPS ]

  1. #pragma segment MenuOption
  2. //*********************************************************************************
  3. //    TOptSolution - Methods
  4. //        inherits all methods and vars from TDialogView
  5. //        overrides method : DoChoice
  6. //*********************************************************************************
  7. //    fSolution    [0]    =    number of grid levels
  8. //                    [1]    =    number of sweeps on momentum equations
  9. //                    [2]    =    number of sweeps on pressure corrections
  10. //                    [3]    =    number of sweeps on scalar equations
  11. //    fAccuracy        =    solution accuracy
  12. //    fIteration            =    maximum iterations
  13. //------------------------------------------------------------------------------------------
  14. //    TOptFlow DoChoice Method... Implementation
  15. //------------------------------------------------------------------------------------------
  16. pascal void TOptSolution::DoChoice(TView *origView, short itsChoice)
  17.     {
  18.     TWindow        * aWindow;
  19.     short             index;
  20.     
  21.     aWindow = this->GetWindow();                                                                // window containing this object
  22.     
  23.     switch (itsChoice)
  24.         {
  25.         case mHScrollBarHit :                                                                        // change a scroll bar?
  26.             long itsValue;                                                                                // the coord of the scroller
  27.             for (index = 1; index < 5; index++)                                                // cycle through all scrollers
  28.                 {
  29.                 this->GetControlName(index,"SR");                                            // get scroller name
  30.                 if (origView == (TScrollBar *) aWindow->FindSubView(tbox.boxID)) // get the scroll bar object
  31.                     {
  32.                     itsValue = ((TScrollBar *) origView)->fLongVal;                    // scroller value
  33.                     this->DisplayValue(index,itsValue);
  34.                     ((TCFDFrontDocument *) fDocument)->SetSolutionOpts(true,index,itsValue,0.0,0); // store the data
  35.                     break;
  36.                     }
  37.                 }
  38.             break;
  39.         }
  40.     inherited::DoChoice(origView,itsChoice);
  41.     this->SaveEdit();
  42.     }
  43.  
  44. //------------------------------------------------------------------------------------------
  45. //    Dismiss the Dialog
  46. //------------------------------------------------------------------------------------------
  47. pascal TCommand * TOptSolution::DoKeyCommand(short ch, short aKeyCode, EventInfo *info)
  48.     {
  49.     inherited::DoKeyCommand(ch,aKeyCode,info);
  50.     this->SaveEdit();
  51.     return gNoChanges;
  52.     }
  53.     
  54. //------------------------------------------------------------------------------------------
  55. //    Store the Accuracy field to the document
  56. //------------------------------------------------------------------------------------------
  57. void TOptSolution::SaveEdit(void)
  58.     {
  59.     TWindow        * aWindow;
  60.     TEditText        * eText;
  61.     char             * accString;
  62.     float             accuracy;
  63.     short            iteration;
  64.     Str255         atemp;
  65.     
  66.     aWindow = this->GetWindow();                                                                // window containing this object
  67.     eText = (TEditText *) aWindow->FindSubView('ED01');
  68.     eText->GetText(atemp);
  69.     accString = p2cstr((StringPtr) atemp);
  70.     accuracy = atof(accString);
  71.     
  72.     eText = (TEditText *) aWindow->FindSubView('ED02');
  73.     eText->GetText(atemp);
  74.     accString = p2cstr((StringPtr) atemp);
  75.     iteration = atoi(accString);
  76.             
  77.     ((TCFDFrontDocument *) fDocument)->SetSolutionOpts(false,0,0L,accuracy,iteration);
  78.     }
  79.     
  80. //------------------------------------------------------------------------------------------
  81. //    Override the bring to front method
  82. //------------------------------------------------------------------------------------------
  83. void TOptSolution::BringToFront(void)
  84.     {
  85.     inherited::BringToFront();
  86.     this->SaveEdit();
  87.     }
  88.  
  89. //------------------------------------------------------------------------------------------
  90. //    Dismiss the Dialog
  91. //------------------------------------------------------------------------------------------
  92. pascal void TOptSolution::DismissDialog(ResType dismisser)
  93.     {
  94.     this->SaveEdit();
  95.     ((TCFDFrontDocument *) fDocument)->SetDialogOn(false,cSolutionDialog);
  96.     inherited::DismissDialog(dismisser);
  97.     }
  98.  
  99. //------------------------------------------------------------------------------------------
  100. //    Decode the print options long int
  101. //------------------------------------------------------------------------------------------
  102. void TOptSolution::MarkScroller (long * scroller, float accuracy, short iteration)
  103.     {
  104.     TWindow         *    aWindow;
  105.     TScrollBar     *    bar;
  106.     TEditText        *    eText;
  107.     StringPtr             pAccuracy;
  108.     char                     sAccuracy[15];
  109.     short index;
  110.     
  111.     aWindow = this->GetWindow();                                                    // get reference to the window
  112.  
  113.     for (index = 1; index < 5; index++)                                            // do all scrollers
  114.         {
  115.         this->GetControlName(index,"SR");                                        // puts scroller name in tbox    
  116.         bar = (TScrollBar *) aWindow->FindSubView(tbox.boxID);        // get pointer to the box
  117.         bar->SetLongVal(scroller[index-1],true);                                // set new value & redraw
  118.         this->DisplayValue(index,scroller[index-1]);                        // set the static display boxes
  119.         }
  120.     sprintf(sAccuracy,"%f",accuracy);                                            // convert accuracy
  121.     pAccuracy = c2pstr(sAccuracy);
  122.     eText = (TEditText *) aWindow->FindSubView('ED01');                // get accuracy window
  123.     eText->SetText(pAccuracy,true);                                            // display accuracy data
  124.  
  125.     sprintf(sAccuracy,"%d",iteration);                                            // convert accuracy
  126.     pAccuracy = c2pstr(sAccuracy);
  127.     eText = (TEditText *) aWindow->FindSubView('ED02');                // get accuracy window
  128.     eText->SetText(pAccuracy,true);                                            // display accuracy data
  129.     }
  130.  
  131. //------------------------------------------------------------------------------------------
  132. //    Display the value associated to the scroll bar
  133. //------------------------------------------------------------------------------------------
  134. void TOptSolution::DisplayValue (short index, long value)
  135.     {
  136.     TWindow        * aWindow;
  137.     TStaticText    * theText;
  138.     StringPtr        pText;
  139.     char             strng[10];
  140.     
  141.     aWindow = this->GetWindow();                                                    // window containing this object
  142.     this->GetControlName(index,"SC");                                            // get associated text field name
  143.     theText = (TStaticText *) aWindow->FindSubView(tbox.boxID); // get  associated text name
  144.     sprintf(strng,"%ld",value);                                                        // create a string
  145.     pText = c2pstr(strng);                                                                // convert to pascal
  146.     theText->SetText(pText,kRedraw);                                            // display the value
  147.     }